﻿using lingopen.IdStrategy;
using lingopen.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Chloe;
using lingopen.AutoMapper;
using lingopen.Entity.System;

namespace lingopen.Application.System.Implements
{
    public class ConfigAppService : AdminAppService, IConfigAppService
    {
        public PagedData<Sys_Config> GetConfigs(Pagination pagination, string keyword)
        {
            var q = this.DbContext.Query<Sys_Config>().FilterDeleted().WhereIfNotNullOrEmpty(keyword, a => a.Name.Contains(keyword) || a.Code.Contains(keyword));
            q = q.OrderBy(a => a.Code);
            PagedData<Sys_Config> ret = q.TakePageData(pagination);
            return ret;
        }

        public Sys_Config GetConfig(string code)
        {
            var q = this.DbContext.Query<Sys_Config>().FilterDeleted().Where(p => p.Code == code);
            return q.FirstOrDefault();
        }


    }
}
